package fr.p10.miage.FactSing.Factory;
import java.util.HashMap;
import java.util.Map;

import fr.p10.miage.FactSing.Product.Product;


public final class Factory {
	private static Map <String , Product> registry = new HashMap <String , Product >();
	private volatile static  Factory instance;
	
		
	public static Factory getInstance(){
		Factory f = instance;
		
		if(f==null){
			synchronized(Factory.class){
				f=instance;
				if (f==null){
					instance = f = new Factory();
				}
			}
		}
		return f;
	}
	
	
	public void registerProduct (String name, Product p){
		registry.put(name, p);
	}
	
	public Product creerProduct(String t){
		return registry.get(t).creerProduct();		
	}


	private Factory() {
		super();
		// TODO Auto-generated constructor stub
	}
}
